#include "redballDialog.h"

//(*InternalHeaders(redballDialog)
#include <wx/xrc/xmlres.h>
//*)

//(*IdInit(redballDialog)
//*)

BEGIN_EVENT_TABLE(redballDialog,wxDialog)
	//(*EventTable(redballDialog)
	//*)
END_EVENT_TABLE()

redballDialog::redballDialog(wxWindow* parent)
{
	//(*Initialize(redballDialog)
	wxXmlResource::Get()->LoadObject(this,parent,_T("redballDialog"),_T("wxDialog"));

	groupblue = (wxStaticBox*)FindWindow(XRCID("ID_STATICBOX2"));
	groupredball = (wxStaticBox*)FindWindow(XRCID("ID_STATICBOX1"));

	cb2 = (wxCheckBox*)FindWindow(XRCID("ID_CHECKBOX3"));
	cb3 = (wxCheckBox*)FindWindow(XRCID("ID_CHECKBOX4"));
	cb4 = (wxCheckBox*)FindWindow(XRCID("ID_CHECKBOX5"));
	cb6 = (wxCheckBox*)FindWindow(XRCID("ID_CHECKBOX7"));
	cb7 = (wxCheckBox*)FindWindow(XRCID("ID_CHECKBOX11"));
	cb11 = (wxCheckBox*)FindWindow(XRCID("ID_CHECKBOX12"));
	cb12 = (wxCheckBox*)FindWindow(XRCID("ID_CHECKBOX13"));
	cb13 = (wxCheckBox*)FindWindow(XRCID("ID_CHECKBOX18"));
	cb18 = (wxCheckBox*)FindWindow(XRCID("ID_CHECKBOX19"));
	cb19 = (wxCheckBox*)FindWindow(XRCID("ID_CHECKBOX25"));
	cb25 = (wxCheckBox*)FindWindow(XRCID("ID_CHECKBOX30"));
	cb30 = (wxCheckBox*)FindWindow(XRCID("ID_CHECKBOX31"));
	cb31 = (wxCheckBox*)FindWindow(XRCID("ID_CHECKBOX33"));
	cb33 = (wxCheckBox*)FindWindow(XRCID("ID_CHECKBOX32"));
	cb32 = (wxCheckBox*)FindWindow(XRCID("ID_CHECKBOX29"));
	cb29 = (wxCheckBox*)FindWindow(XRCID("ID_CHECKBOX28"));
	cb28 = (wxCheckBox*)FindWindow(XRCID("ID_CHECKBOX27"));
	cb27 = (wxCheckBox*)FindWindow(XRCID("ID_CHECKBOX26"));
	cb26 = (wxCheckBox*)FindWindow(XRCID("ID_CHECKBOX24"));
	cb24 = (wxCheckBox*)FindWindow(XRCID("ID_CHECKBOX23"));
	cb23 = (wxCheckBox*)FindWindow(XRCID("ID_CHECKBOX22"));
	cb22 = (wxCheckBox*)FindWindow(XRCID("ID_CHECKBOX21"));
	cb21 = (wxCheckBox*)FindWindow(XRCID("ID_CHECKBOX20"));
	cb20 = (wxCheckBox*)FindWindow(XRCID("ID_CHECKBOX17"));
	cb17 = (wxCheckBox*)FindWindow(XRCID("ID_CHECKBOX16"));
	cb16 = (wxCheckBox*)FindWindow(XRCID("ID_CHECKBOX15"));
	cb15 = (wxCheckBox*)FindWindow(XRCID("ID_CHECKBOX14"));
	cb14 = (wxCheckBox*)FindWindow(XRCID("ID_CHECKBOX10"));
	cb10 = (wxCheckBox*)FindWindow(XRCID("ID_CHECKBOX9"));
	cb8 = (wxCheckBox*)FindWindow(XRCID("ID_CHECKBOX8"));
	cb9 = (wxCheckBox*)FindWindow(XRCID("ID_CHECKBOX6"));
	cb5 = (wxCheckBox*)FindWindow(XRCID("ID_CHECKBOX1"));
	cb1 = (wxCheckBox*)FindWindow(XRCID("ID_CHECKBOX2"));
	balltext = (wxTextCtrl*)FindWindow(XRCID("ID_TEXTCTRL1"));
	Button1 = (wxButton*)FindWindow(XRCID("wxID_OK"));
	Button2 = (wxButton*)FindWindow(XRCID("wxID_CANCEL"));
	blue1 = (wxCheckBox*)FindWindow(XRCID("ID_CHECKBOX43"));
	blue15 = (wxCheckBox*)FindWindow(XRCID("ID_CHECKBOX49"));
	blue13 = (wxCheckBox*)FindWindow(XRCID("ID_CHECKBOX48"));
	blue11 = (wxCheckBox*)FindWindow(XRCID("ID_CHECKBOX47"));
	blue9 = (wxCheckBox*)FindWindow(XRCID("ID_CHECKBOX46"));
	blue7 = (wxCheckBox*)FindWindow(XRCID("ID_CHECKBOX45"));
	blue5 = (wxCheckBox*)FindWindow(XRCID("ID_CHECKBOX44"));
	blue3 = (wxCheckBox*)FindWindow(XRCID("ID_CHECKBOX35"));
	blue2 = (wxCheckBox*)FindWindow(XRCID("ID_CHECKBOX36"));
	blue4 = (wxCheckBox*)FindWindow(XRCID("ID_CHECKBOX37"));
	blue16 = (wxCheckBox*)FindWindow(XRCID("ID_CHECKBOX42"));
	blue14 = (wxCheckBox*)FindWindow(XRCID("ID_CHECKBOX41"));
	blue12 = (wxCheckBox*)FindWindow(XRCID("ID_CHECKBOX40"));
	blue10 = (wxCheckBox*)FindWindow(XRCID("ID_CHECKBOX39"));
	blue8 = (wxCheckBox*)FindWindow(XRCID("ID_CHECKBOX38"));
	blue6 = (wxCheckBox*)FindWindow(XRCID("ID_CHECKBOX34"));
	//*)


Connect(XRCID("ID_CHECKBOX3"), wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&redballDialog::OnRedBallCheckBoxClick);
Connect(XRCID("ID_CHECKBOX4"), wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&redballDialog::OnRedBallCheckBoxClick);
Connect(XRCID("ID_CHECKBOX5"), wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&redballDialog::OnRedBallCheckBoxClick);
Connect(XRCID("ID_CHECKBOX7"), wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&redballDialog::OnRedBallCheckBoxClick);
Connect(XRCID("ID_CHECKBOX11"),wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&redballDialog::OnRedBallCheckBoxClick);
Connect(XRCID("ID_CHECKBOX12"),wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&redballDialog::OnRedBallCheckBoxClick);
Connect(XRCID("ID_CHECKBOX13"),wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&redballDialog::OnRedBallCheckBoxClick);
Connect(XRCID("ID_CHECKBOX18"),wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&redballDialog::OnRedBallCheckBoxClick);
Connect(XRCID("ID_CHECKBOX19"),wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&redballDialog::OnRedBallCheckBoxClick);
Connect(XRCID("ID_CHECKBOX25"),wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&redballDialog::OnRedBallCheckBoxClick);
Connect(XRCID("ID_CHECKBOX30"),wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&redballDialog::OnRedBallCheckBoxClick);
Connect(XRCID("ID_CHECKBOX31"),wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&redballDialog::OnRedBallCheckBoxClick);
Connect(XRCID("ID_CHECKBOX33"),wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&redballDialog::OnRedBallCheckBoxClick);
Connect(XRCID("ID_CHECKBOX32"),wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&redballDialog::OnRedBallCheckBoxClick);
Connect(XRCID("ID_CHECKBOX29"),wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&redballDialog::OnRedBallCheckBoxClick);
Connect(XRCID("ID_CHECKBOX28"),wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&redballDialog::OnRedBallCheckBoxClick);
Connect(XRCID("ID_CHECKBOX27"),wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&redballDialog::OnRedBallCheckBoxClick);
Connect(XRCID("ID_CHECKBOX26"),wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&redballDialog::OnRedBallCheckBoxClick);
Connect(XRCID("ID_CHECKBOX24"),wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&redballDialog::OnRedBallCheckBoxClick);
Connect(XRCID("ID_CHECKBOX23"),wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&redballDialog::OnRedBallCheckBoxClick);
Connect(XRCID("ID_CHECKBOX22"),wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&redballDialog::OnRedBallCheckBoxClick);
Connect(XRCID("ID_CHECKBOX21"),wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&redballDialog::OnRedBallCheckBoxClick);
Connect(XRCID("ID_CHECKBOX20"),wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&redballDialog::OnRedBallCheckBoxClick);
Connect(XRCID("ID_CHECKBOX17"),wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&redballDialog::OnRedBallCheckBoxClick);
Connect(XRCID("ID_CHECKBOX16"),wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&redballDialog::OnRedBallCheckBoxClick);
Connect(XRCID("ID_CHECKBOX15"),wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&redballDialog::OnRedBallCheckBoxClick);
Connect(XRCID("ID_CHECKBOX14"),wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&redballDialog::OnRedBallCheckBoxClick);
Connect(XRCID("ID_CHECKBOX10"),wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&redballDialog::OnRedBallCheckBoxClick);
Connect(XRCID("ID_CHECKBOX9"), wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&redballDialog::OnRedBallCheckBoxClick);
Connect(XRCID("ID_CHECKBOX8"), wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&redballDialog::OnRedBallCheckBoxClick);
Connect(XRCID("ID_CHECKBOX6"), wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&redballDialog::OnRedBallCheckBoxClick);
Connect(XRCID("ID_CHECKBOX1"), wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&redballDialog::OnRedBallCheckBoxClick);
Connect(XRCID("ID_CHECKBOX2"), wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&redballDialog::OnRedBallCheckBoxClick);
//blue ball click event
Connect(XRCID("ID_CHECKBOX43"),wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&redballDialog::OnBlueBallCheckBoxClick);
Connect(XRCID("ID_CHECKBOX49"),wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&redballDialog::OnBlueBallCheckBoxClick);
Connect(XRCID("ID_CHECKBOX48"),wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&redballDialog::OnBlueBallCheckBoxClick);
Connect(XRCID("ID_CHECKBOX47"),wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&redballDialog::OnBlueBallCheckBoxClick);
Connect(XRCID("ID_CHECKBOX46"),wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&redballDialog::OnBlueBallCheckBoxClick);
Connect(XRCID("ID_CHECKBOX45"),wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&redballDialog::OnBlueBallCheckBoxClick);
Connect(XRCID("ID_CHECKBOX44"),wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&redballDialog::OnBlueBallCheckBoxClick);
Connect(XRCID("ID_CHECKBOX35"),wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&redballDialog::OnBlueBallCheckBoxClick);
Connect(XRCID("ID_CHECKBOX36"),wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&redballDialog::OnBlueBallCheckBoxClick);
Connect(XRCID("ID_CHECKBOX37"),wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&redballDialog::OnBlueBallCheckBoxClick);
Connect(XRCID("ID_CHECKBOX42"),wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&redballDialog::OnBlueBallCheckBoxClick);
Connect(XRCID("ID_CHECKBOX41"),wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&redballDialog::OnBlueBallCheckBoxClick);
Connect(XRCID("ID_CHECKBOX40"),wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&redballDialog::OnBlueBallCheckBoxClick);
Connect(XRCID("ID_CHECKBOX39"),wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&redballDialog::OnBlueBallCheckBoxClick);
Connect(XRCID("ID_CHECKBOX38"),wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&redballDialog::OnBlueBallCheckBoxClick);
Connect(XRCID("ID_CHECKBOX34"),wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&redballDialog::OnBlueBallCheckBoxClick);
cb2  ->SetOwnForegroundColour(*wxRED);
cb3  ->SetOwnForegroundColour(*wxRED);
cb4  ->SetOwnForegroundColour(*wxRED);
cb6  ->SetOwnForegroundColour(*wxRED);
cb7  ->SetOwnForegroundColour(*wxRED);
cb11 ->SetOwnForegroundColour(*wxRED);
cb12 ->SetOwnForegroundColour(*wxRED);
cb13 ->SetOwnForegroundColour(*wxRED);
cb18 ->SetOwnForegroundColour(*wxRED);
cb19 ->SetOwnForegroundColour(*wxRED);
cb25 ->SetOwnForegroundColour(*wxRED);
cb30 ->SetOwnForegroundColour(*wxRED);
cb31 ->SetOwnForegroundColour(*wxRED);
cb33 ->SetOwnForegroundColour(*wxRED);
cb32 ->SetOwnForegroundColour(*wxRED);
cb29 ->SetOwnForegroundColour(*wxRED);
cb28 ->SetOwnForegroundColour(*wxRED);
cb27 ->SetOwnForegroundColour(*wxRED);
cb26 ->SetOwnForegroundColour(*wxRED);
cb24 ->SetOwnForegroundColour(*wxRED);
cb23 ->SetOwnForegroundColour(*wxRED);
cb22 ->SetOwnForegroundColour(*wxRED);
cb21 ->SetOwnForegroundColour(*wxRED);
cb20 ->SetOwnForegroundColour(*wxRED);
cb17 ->SetOwnForegroundColour(*wxRED);
cb16 ->SetOwnForegroundColour(*wxRED);
cb15 ->SetOwnForegroundColour(*wxRED);
cb14 ->SetOwnForegroundColour(*wxRED);
cb10 ->SetOwnForegroundColour(*wxRED);
cb8  ->SetOwnForegroundColour(*wxRED);
cb9  ->SetOwnForegroundColour(*wxRED);
cb5  ->SetOwnForegroundColour(*wxRED);
cb1  ->SetOwnForegroundColour(*wxRED);
	blue1  ->SetOwnForegroundColour(*wxBLUE);
	blue15 ->SetOwnForegroundColour(*wxBLUE);
	blue13 ->SetOwnForegroundColour(*wxBLUE);
	blue11 ->SetOwnForegroundColour(*wxBLUE);
	blue9  ->SetOwnForegroundColour(*wxBLUE);
	blue7  ->SetOwnForegroundColour(*wxBLUE);
	blue5  ->SetOwnForegroundColour(*wxBLUE);
	blue3  ->SetOwnForegroundColour(*wxBLUE);
	blue2  ->SetOwnForegroundColour(*wxBLUE);
	blue4  ->SetOwnForegroundColour(*wxBLUE);
	blue16 ->SetOwnForegroundColour(*wxBLUE);
	blue14 ->SetOwnForegroundColour(*wxBLUE);
	blue12 ->SetOwnForegroundColour(*wxBLUE);
	blue10 ->SetOwnForegroundColour(*wxBLUE);
	blue8  ->SetOwnForegroundColour(*wxBLUE);
	blue6  ->SetOwnForegroundColour(*wxBLUE);
    this->Refresh();
}

redballDialog::~redballDialog()
{
	//(*Destroy(redballDialog)
	//*)
}


void redballDialog::OnRedBallCheckBoxClick(wxCommandEvent& event)
{
selectedredball.Clear();
	if(cb1->IsChecked())selectedredball.Add(_("01"));
   if(cb2->IsChecked())selectedredball.Add(_("02"));
	if(cb3->IsChecked())selectedredball.Add(_("03"));
	if(cb4->IsChecked())selectedredball.Add(_("04"));
	if(cb5->IsChecked())selectedredball.Add(_("05"));
	if(cb6->IsChecked())selectedredball.Add(_("06"));
	if(cb7->IsChecked())selectedredball.Add(_("07"));
  if(cb8->IsChecked())selectedredball.Add(_("08"));
	if(cb9->IsChecked())selectedredball.Add(_("09"));
	if(cb10->IsChecked())selectedredball.Add(_("10"));
	if(cb11->IsChecked())selectedredball.Add(_("11"));
	if(cb12->IsChecked())selectedredball.Add(_("12"));
	if(cb13->IsChecked())selectedredball.Add(_("13"));
	if(cb14->IsChecked())selectedredball.Add(_("14"));
	if(cb15->IsChecked())selectedredball.Add(_("15"));
	if(cb16->IsChecked())selectedredball.Add(_("16"));
	if(cb17->IsChecked())selectedredball.Add(_("17"));
	if(cb18->IsChecked())selectedredball.Add(_("18"));
	if(cb19->IsChecked())selectedredball.Add(_("19"));
	if(cb20->IsChecked())selectedredball.Add(_("20"));
	if(cb21->IsChecked())selectedredball.Add(_("21"));
	if(cb22->IsChecked())selectedredball.Add(_("22"));
	if(cb23->IsChecked())selectedredball.Add(_("23"));
	if(cb24->IsChecked())selectedredball.Add(_("24"));
	if(cb25->IsChecked())selectedredball.Add(_("25"));
	if(cb26->IsChecked())selectedredball.Add(_("26"));
	if(cb27->IsChecked())selectedredball.Add(_("27"));
	if(cb28->IsChecked())selectedredball.Add(_("28"));
	if(cb29->IsChecked())selectedredball.Add(_("29"));
	if(cb30->IsChecked())selectedredball.Add(_("30"));
	if(cb31->IsChecked())selectedredball.Add(_("31"));
	if(cb32->IsChecked())selectedredball.Add(_("32"));
	if(cb33->IsChecked())selectedredball.Add(_("33"));
wxString bluetext=(selectedblueball.GetCount()>0?_("+")+arrary2string(selectedblueball):wxString(_("")));

balltext->SetValue(arrary2string(selectedredball)+bluetext);
}
void redballDialog::OnBlueBallCheckBoxClick(wxCommandEvent& event)
{
selectedblueball.Clear();
if(blue1->IsChecked())selectedblueball.Add(_("01"));
if(blue2->IsChecked())selectedblueball.Add(_("02"));
if(blue3->IsChecked())selectedblueball.Add(_("03"));
if(blue4->IsChecked())selectedblueball.Add(_("04"));
if(blue5->IsChecked())selectedblueball.Add(_("05"));
if(blue6->IsChecked())selectedblueball.Add(_("06"));
if(blue7->IsChecked())selectedblueball.Add(_("07"));
if(blue8->IsChecked())selectedblueball.Add(_("08"));
if(blue9->IsChecked())selectedblueball.Add(_("09"));
if(blue10->IsChecked())selectedblueball.Add(_("10"));
if(blue11->IsChecked())selectedblueball.Add(_("11"));
if(blue12->IsChecked())selectedblueball.Add(_("12"));
if(blue13->IsChecked())selectedblueball.Add(_("13"));
if(blue14->IsChecked())selectedblueball.Add(_("14"));
if(blue15->IsChecked())selectedblueball.Add(_("15"));
if(blue16->IsChecked())selectedblueball.Add(_("16"));

wxString redtext=(selectedredball.GetCount()>0?arrary2string(selectedredball):wxString(_("")));
balltext->SetValue(redtext+_("+")+arrary2string(selectedblueball));
}


void redballDialog::parseString(wxArrayString redballs)
{
    selectedredball=redballs;
if(selectedredball.GetCount()<0)return;
for(int i=0;i<selectedredball.GetCount();i++)
  {
   long ball;
   selectedredball[i].ToLong(&ball,10);
   switch(ball)
    {
     case 1:cb1->SetValue(true); break;
     case 2:cb2->SetValue(true); break;
     case 3:cb3->SetValue(true); break;
     case 4:cb4->SetValue(true); break;
     case 5:cb5->SetValue(true); break;
     case 6:cb6->SetValue(true); break;
     case 7:cb7->SetValue(true); break;
     case 8:cb8->SetValue(true); break;
     case 9:cb9->SetValue(true); break;
     case 10:cb10->SetValue(true); break;
     case 11:cb11->SetValue(true); break;
     case 12:cb12->SetValue(true); break;
     case 13:cb13->SetValue(true); break;
     case 14:cb14->SetValue(true); break;
     case 15:cb15->SetValue(true); break;
     case 16:cb16->SetValue(true); break;
     case 17:cb17->SetValue(true); break;
     case 18:cb18->SetValue(true); break;
     case 19:cb19->SetValue(true); break;
     case 20:cb20->SetValue(true); break;
     case 21:cb21->SetValue(true); break;
     case 22:cb22->SetValue(true); break;
     case 23:cb23->SetValue(true); break;
     case 24:cb24->SetValue(true); break;
     case 25:cb25->SetValue(true); break;
     case 26:cb26->SetValue(true); break;
     case 27:cb27->SetValue(true); break;
     case 28:cb28->SetValue(true); break;
     case 29:cb29->SetValue(true); break;
     case 30:cb30->SetValue(true); break;
     case 31:cb31->SetValue(true); break;
     case 32:cb32->SetValue(true); break;
     case 33:cb33->SetValue(true); break;
    }
  }
}


